﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Newtonsoft.Json;

public partial class uc_header : System.Web.UI.UserControl
{
    public string str01 = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        str01 = ShowWeather();
    }

    protected string ShowWeather()
    {
        StringBuilder sb = new StringBuilder();
        try
        {
            Basic b = new Basic();
            string str = OperMethod.GetPageByUrl(b.jsonUrl + "comm/weather.ashx", "gb2312");
            WeatherEnty obj = new WeatherEnty();
            if (!String.IsNullOrEmpty(str))
                obj = JsonConvert.DeserializeObject<WeatherEnty>(str);
            if (obj != null)
            {
                sb.AppendFormat("<div class=\"fl mr10\" ><img src=\"http://i.ymcps.com/www/images/weather/w{0}.png\" width=\"50\" alt=\"\" /></div>", obj.weather);
                sb.AppendFormat("<div class=\"fl lh20 link\">");
                sb.AppendFormat("<span class=\"title\">股市天气</span><br />");
                sb.AppendFormat("<span class=\"red\">{0}</span><br />", GetWather(OTO.ToInt(obj.weather, 0)));
                sb.AppendFormat("{0}<span class=\"ml10\"><a href=\"http://hq.emoney.cn/\">详细>></a></span>", obj.content);
                sb.AppendFormat("</div>");
            }
        }
        catch
        {
            sb = new StringBuilder();
        }
        return sb.ToString();
    }

    protected string GetWather(int v)
    {
        string rel = "";
        switch (v)
        {
            case 1:
                rel = "艳阳高照";
                break;
            case 2:
                rel = "阳光普照";
                break;
            case 3:
                rel = "中雨";
                break;
            case 4:
                rel = "雷阵雨";
                break;
            case 5:
                rel = "多云转晴";
                break;
            case 6:
                rel = "多云";
                break;
            case 7:
                rel = "多云";
                break;
            case 8:
                rel = "小雨";
                break;
            case 9:
                rel = "冬日暖阳";
                break;
            case 10:
                rel = "多云";
                break;
            case 11:
                rel = "冬日暖阳";
                break;
            case 12:
                rel = "小雪";
                break;
            case 13:
                rel = "冬日暖阳";
                break;
            case 14:
                rel = "晴转多云";
                break;
            case 15:
                rel = "阴雨绵绵";
                break;
            case 16:
                rel = "漫天飞雪";
                break;
            case 17:
                rel = "雷阵雨";
                break;
            case 18:
                rel = "倾盆大雨";
                break;
        }
        return rel;
    }

}